package java_thinking.unit_10._10_3;

/**
 * @Description : 用.this与.new 生成对外部类对象的引用
 * @author: cww
 * @DateTime: 2019-03-09 15:07
 */

class DotThis {
    void f(){
        System.out.println("DotThis.f()");
    }
    public class Inner{
        public DotThis outer(){
            return DotThis.this;
        }
    }

    public Inner getInner(){
        return new Inner();
    }
}
class Unit103Demo {
    public static void main(String[] args) {
        DotThis dotThis = new DotThis();
        DotThis.Inner inner = dotThis.getInner();
        DotThis dotThis1 = inner.outer();
        dotThis1.f();
    }
}

/**
 * 直接创建某个类的内部类.new
 */
class DotNew{
    public class Inner{};

    public static void main(String[] args) {
        DotNew dotNew = new DotNew();

        DotNew.Inner inner = dotNew.new Inner();

    }
}